<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../Vue.js"></script>
    <style>
        .divs {
            color: #26a09c;
            font-size: 30px;
        }

        .imgs {
            width: 100px;
            height: 200px;
            background-color: blue;
        }

        .aivs {
            display: none;
        }
    </style>

</head>

<body>
    <div class="div">
        <div @click="click" :class="classnames">胡歌</div>
    </div>
    <script>

        const obj = {
            data() {
                return {
                    // 将类名数组动态绑定
                    classnames: [
                        'divs',
                    ]
                }
            },
            methods: {
                click() {
                    // 点击胡歌就把imgs这个类名添加到classname数组里面
                    this.classnames.push(" imgs")
                    // 就可以用数组的方法去动态添加类名
                    //    thi.classnames.pop()删除


                }
            }
        }
        const app = Vue.createApp(obj).mount('.div')
    </script>
</body>

</html>